Skip to content

feat: Run/Debug support with optimized classpath resolution#24

Open
runchen0919 wants to merge 9 commits into
monkey666-cr:mainfrom
runchen0919:feat/debug-optimization
Open

feat: Run/Debug support with optimized classpath resolution#24
runchen0919 wants to merge 9 commits into
monkey666-cr:mainfrom
runchen0919:feat/debug-optimization

Conversation

@runchen0919
Copy link
Copy Markdown
Contributor

@runchen0919 runchen0919 commented May 21, 2026

Summary

  • output_jars serialization: Include target's own compiled JARs as LIB entries in JNI classpath serialization, fixing ClassNotFoundException when Bazel is the build system
  • Auto-build before debug: Register a DebugConfigurationProvider that runs bazel build before debug launch, with cancellable progress notification and "Debug Anyway" fallback
  • Plain build for pre-debug: Replace heavyweight aspect build with lightweight bazel build for pre-debug compilation, avoiding aspect evaluation overhead
  • Runtime classpath resolver: Register IRuntimeClasspathEntryResolver using in-memory JavaCore.getClasspathContainer() instead of file I/O, optimizing debug stackTrace resolution from O(n²) to O(1)

Test plan

  • Verify classpath includes output_jars for Bazel java_library targets
  • Confirm auto-build triggers before Run/Debug and shows progress notification
  • Test build failure scenario: "Debug Anyway" and cancel options work correctly
  • Validate debug stackTrace resolves correctly with the new in-memory resolver
  • Run cargo test --workspace and mvn test to confirm no regressions

🤖 Generated with Claude Code

runchen0919 and others added 9 commits May 21, 2026 17:55
…g support

When JavaBuilder is disabled (Bazel is the build system), the Eclipse output
location is empty. This causes ClassNotFoundException at runtime because
the target's own compiled JARs were computed but never serialized across
the JNI boundary. Include output_jars as LIB entries in
to_pipe_delimited_entries(), deduplicated against existing dependency
entries to avoid duplicates from java_import targets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Register a DebugConfigurationProvider that intercepts Java debug
sessions and runs `bazel build` for the project's targets before the
debugger starts. This ensures compiled JARs exist in bazel-bin/ so the
runtime classpath (populated by Phase 1's output_jars serialization)
resolves successfully.

On build failure the user can choose "Debug Anyway" or cancel the
launch. The build progress is shown as a cancellable notification.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace aspect build with a lightweight plain `bazel build` for
pre-debug target compilation. This avoids the overhead of aspect
evaluation and graph updates when only compilation is needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lver

Register IRuntimeClasspathEntryResolver for BAZEL_CONTAINER to bypass
O(n²) computeDefaultContainerEntries() recursion. Use in-memory
JavaCore.getClasspathContainer() instead of file I/O, and scope
resolution to the active debug project for O(1) lookup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
For java_binary targets, gather output_jars from all transitive
dependencies so the debug runtime classpath includes the full set of
required jars. Small stub jars (<1KB) are filtered out. After pre-debug
build, clear the runtime classpath cache and refresh the classpath
container to pick up freshly built artifacts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…spath

Instead of eagerly picking between full/compile JARs at graph population
time, store all JAR variants (full, compile, runtime) in ResolvedJar and
resolve lazily via effective_path(). This enables accurate classpath
resolution for debug sessions where runtime JARs may only appear after
a build. Also centralizes BazelProjectView in BazelBridge and adds
build failure detection for pre-debug builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ed cache invalidation

Extract setActiveDebugProject into a standalone JDT command invoked
early in resolveDebugConfiguration, so the runtime classpath filter is
active before the build step. Replace full cache clear with per-project
clearCacheForProject for more precise invalidation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant